package com.heima.admin.controller;

import com.heima.common.dtos.ResponseResult;
import com.heima.dto.WmNews;
import com.heima.feign.WmUserFeignClient;
import com.heima.model.admin.dtos.NewsAuthDto;
import com.heima.model.wemedia.dto.WmNewsPageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class NewsController {

    @Autowired
    private WmUserFeignClient wmUserFeignClient;


    /**
     * 文章列表查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/news_auth/list")
    public ResponseResult authList(@RequestBody WmNewsPageDTO dto) {
        return ResponseResult.ok(wmUserFeignClient.authList(dto));
    }

    @PostMapping("/api/v1/news_auth/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto) {
        Integer id = dto.getId();
        WmNews wmNews = wmUserFeignClient.authPass(id);
        return ResponseResult.ok();
    }

    /**
     * 自媒体文章审核不通过
     */
    @PostMapping("/api/v1/news_auth/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto) {
        wmUserFeignClient.authFail(dto);
        return ResponseResult.ok();
    }
}
